<?php

class Application_Form_FormLogin extends Zend_Form
{

    public function init()
    {
        $this->setName('login');
        $this->setMethod('post');
        $this->setAction('/account/login');
        $this->setAttrib('class', 'mod-login');
        $this->setDecorators(array('FormElements','Form'));
        
        $email = new Zend_Form_Element_Text('email');
        $email->setAttrib('placeholder', 'Usuario');
        $email->setAttrib('size', 10);
        $email->removeDecorator('label');
        $email->removeDecorator('DtDdWrapper');
        $email->removeDecorator('htmlTag');
        //Validate
        $email->setRequired(true);
        $email->addValidator('emailAddress');
		$email->addErrorMessage('Verifique el email ingresado.');

        $pswd = new Zend_Form_Element_Password('pwd');
        $pswd->setAttrib('placeholder', 'Password');
        $pswd->setAttrib('size', 10);
        $pswd->removeDecorator('label');
        $pswd->removeDecorator('DtDdWrapper');
        $pswd->removeDecorator('htmlTag');
        //Validate
        $pswd->setRequired(true);
        $pswd->addValidator('StringLength', false, array(6,15));
        $pswd->addErrorMessage('Usuario o Password incorrecto.');


        $submit = new Zend_Form_Element_Submit('signin');
        $submit->setLabel('Sign In');
        $submit->setAttrib('class', 'btn');
        $submit->removeDecorator('DtDdWrapper');
		
		$hash = new Zend_Form_Element_Hash('csrf', array('salt' => 'unique'));
		$hash->setAttrib('class', 'mod-csrf');
		$hash->removeDecorator('DtDdWrapper');
		$hash->removeDecorator('htmlTag');
		$hash->removeDecorator('label');
		
		
        //add to the form
        $this->addElements(array($email, $pswd, $hash, $submit));

        //anti CSFR
        // $this->addElement('hash', 'csrf', array('salt' => 'unique'));
    }


}

